漏洞复现
网上内容
首先在目录里建立111.txt
然后,获取formhash:7b2bf0ce
于是可以构建payload:
1 | http://127.0.0.1/home.php?mod=spacecp&ac=profile&op=base |
##漏洞分析
我们来看下源码,这里主要是spacecp_profile.php的问题
首先,我们从漏洞出发,我们先从删除函数开始:1
2
3
4
5
6
7
8
9
10# 178
if($_GET['deletefile'] && is_array($_GET['deletefile'])) {
foreach($_GET['deletefile'] as $key => $value) {
if(isset($_G['cache']['profilesetting'][$key]) && $_G['cache']['profilesetting'][$key]['formtype'] == 'file') {
@unlink(getglobal('setting/attachdir').'./profile/'.$space[$key]);
@unlink(getglobal('setting/attachdir').'./profile/'.$verifyinfo['field'][$key]);
$verifyarr[$key] = $setarr[$key] = '';
}
}
}
可以看到,这个要求formtype是file,就会触发unlink
我们发现这次改动的228行有@unlink(getglobal('setting/attachdir').'./profile/'.$space[$key]);
,也就是这次漏洞所在,我们看看语句成立的条件
1 | if($_FILES) { |
也就是上传文件,那么现在就是看看这个$space[$key]
了,回溯下变量,我们发现,key是可以被payload里的用户资料所操作的,我们看下payload里用的birthprovince
,
1 | if(isset($_POST['birthprovince'])) { |
可以看到这个就可以控制$space[$key]
,而且没有什么限制,而一切的条件就是70行的if(submitcheck('profilesubmit')) {
所以,我们的payload会有profilesubmit=1